@extends('admin.layouts.head')
@section('content')
    <body>
    <div id="app">
        <div class="wrapper -header-fixed">

        @include('admin.layouts.navbar')
        @include('admin.layouts.sidebar')

        <!-- 内容页开始-->
            <div class="content-container">
                <div class="container-fluid">
                    <div class="page-content">

                        <nav aria-label="breadcrumb">
                            <ol class="breadcrumb">
                                <li class="breadcrumb-item"><a href="{{ route('admin.dashboard') }}">仪表盘</a></li>
                                <li class="breadcrumb-item active" aria-current="page">广告价格</li>
                            </ol>
                        </nav>

                        <div class="card">
                            <div class="card-body">

                                <div class="row">
                                    <div class="col-lg-5">

                                        <div class="col-lg-12">
                                            <div class="form-group">
                                                <label>套黄价格：</label>
                                                <input type="text" class="form-control" id="yellow" value="{{ $ad_price->yellow }}">
                                            </div>
                                        </div>
                                        <div class="col-lg-12">
                                            <div class="form-group">
                                                <label>全天套黄价格：</label>
                                                <input type="text" class="form-control" id="all_day_yellow" value="{{ $ad_price->all_day_yellow }}">
                                            </div>
                                        </div>
                                        <div class="col-lg-12">
                                            <div class="form-group">
                                                <label>通宵价格：</label>
                                                <input type="text" class="form-control" id="overnight" value="{{ $ad_price->overnight }}">
                                            </div>
                                        </div>
                                        <div class="col-lg-12">
                                            <div class="form-group">
                                                <label>固定通宵价格：</label>
                                                <input type="text" class="form-control" id="fixed_overnight" value="{{ $ad_price->fixed_overnight }}">
                                            </div>
                                        </div>
                                        <div class="col-lg-12">
                                            <div class="form-group">
                                                <label>全天精品价格：</label>
                                                <input type="text" class="form-control" id="all_day_boutique" value="{{ $ad_price->all_day_boutique }}">
                                            </div>
                                        </div>

                                        <div class="col-lg-12">
                                            <div class="form-group">
                                                <button class="btn btn-primary" onclick="operation_tip()">提交</button>
                                            </div>
                                        </div>

                                    </div> <!-- .col -->
                                </div> <!-- .row -->
                            </div> <!-- .card-body -->
                        </div> <!-- .card -->

                    </div> <!-- .page-content -->
                </div> <!-- .container-fluid -->
            </div> <!-- .content-container -->
        </div> <!-- .wrapper -->
    </div> <!-- #app -->

    <script src="{{ mix('js/app.js') }}"></script>
    <script src="{{ asset('/js/main.js') }}"></script>
    <script>

        let isLoading = false;

        //提交
        function submit() {

            if (!$('#yellow').val()) {
                toast('套黄价格 不能为空');
                return false
            }
            if (!$('#all_day_yellow').val()) {
                toast('全天套黄价格 不能为空。');
                return false
            }
            if (!$('#overnight').val()) {
                toast('通宵价格 不能为空。');
                return false
            }
            if (!$('#fixed_overnight').val()) {
                toast('固定通宵价格 不能为空。');
                return false
            }
            if (!$('#all_day_boutique').val()) {
                toast('全天精品 不能为空。');
                return false
            }

            if (isLoading === false) {
                isLoading = true;

                axios.post('{{route('admin.ad.store')}} ', {
                    yellow: $('#yellow').val(),
                    all_day_yellow: $('#all_day_yellow').val(),
                    overnight: $('#overnight').val(),
                    fixed_overnight: $('#fixed_overnight').val(),
                    all_day_boutique: $('#all_day_boutique').val(),
                })
                    .then(function (response) {
                        isLoading = false;
                        toast(response.data.message);
                    })
                    .catch(function (error) {
                        isLoading = false;
                        $.each(error.response.data.errors, function (index, object) {
                            toast(object[0]);
                            return false;
                        });
                    })
            }
        }
    </script>

    </body>

@endsection
